﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using MobiSms.Library;
using MobiSms.Library.Extensions;
using MobiSms.Library.Helpers;

namespace MobiSms.ViewModel
{
    public class PreferenceViewModel:ViewModelBase
    {
        public IEnumerable<string> Languages
        {
            get
            {
                yield return "zh-CN";
                yield return "en-US";
            }
        }

        public ICommand CleanCommand
        {
            get
            {
                return new GenericCommand()
                {
                    ExecuteCallback = delegate {
                        if (MessageBox.Show(Application.Current.FindResource<string>(LanguageKeys.IDS_NOTIFICATION_CLEAN_DATA), Application.Current.FindResource<string>(LanguageKeys.IDS_NOTIFICATION_DELETE_COMFIRM_TITLE), MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                        {
                            try
                            {
                                Database.CollectionOfMessages.DeleteAllOnSubmit(Database.CollectionOfMessages);
                                Database.CollectionOfMobiles.DeleteAllOnSubmit(Database.CollectionOfMobiles);
                                Database.CollectionOfReplies.DeleteAllOnSubmit(Database.CollectionOfReplies);
                                Database.CollectionOfSerialNumbers.DeleteAllOnSubmit(Database.CollectionOfSerialNumbers);
                                Submit();
                                MessageBox.Show(Application.Current.FindResource<string>(LanguageKeys.IDS_NOTIFICATION_DONE));
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                                LogHelper.WriteLog(new LogInfo("Data", ex));
                            }
                        }
                    }
                };
            }
        }
    }
}
